
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>我的笔记</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="Termux,Linux学习笔记，为了记笔记，又顺便学习了点hexo">
<meta property="og:type" content="website">
<meta property="og:title" content="我的笔记">
<meta property="og:url" content="https://gitee.com/superigbt_superigbt/superigbt_superigbt/page/3/index.html">
<meta property="og:site_name" content="我的笔记">
<meta property="og:description" content="Termux,Linux学习笔记，为了记笔记，又顺便学习了点hexo">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="Frank.Li">
<meta name="twitter:card" content="summary">
  
    <link rel="alternative" href="/atom.xml" title="我的笔记" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
<link rel="stylesheet" href="/css/style.css">

  <!--[if lt IE 9]><script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7/html5shiv.min.js"></script><![endif]-->
  
<meta name="generator" content="Hexo 6.0.0"></head>
<body>
<div id="container">
  <div id="wrap">
    <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">我的笔记</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">首页</a>
        
          <a class="main-nav-link" href="/archives">按时间</a>
        
          <a class="main-nav-link" href="/about">关于我</a>
        
          <a class="main-nav-link" href="/categories/%E6%91%98%E6%8A%84%E4%B8%8E%E9%9A%8F%E7%AC%94">摘抄，随笔</a>
        
          <a class="main-nav-link" href="/categories/%E5%BC%80%E5%85%B3%E7%94%B5%E6%BA%90">开关电源</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//www.baidu.com/baidu" method="get" accept-charset="utf-8" class="search-form">
          <input type="search" name="word" maxlength="20" class="search-form-input" placeholder="Search">
          <input type="submit" value="" class="search-form-submit">
          <input name=tn type=hidden value="bds">
          <input name=cl type=hidden value="3">
          <input name=ct type=hidden value="2097152">
          <input type="hidden" name="si" value="gitee.com/superigbt_superigbt/superigbt_superigbt">
        </form>
      </div>
    </div>
  </div>
</header>
    <div class="outer">
      <section id="main">
  
    <article id="post-flask-global-var3" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2021/11/02/flask-global-var3/" class="article-date">
  <time datetime="2021-11-02T02:19:00.000Z" itemprop="datePublished">2021-11-02</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/python%E5%AD%A6%E4%B9%A0/">python学习</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2021/11/02/flask-global-var3/">flask全局变量三，视图间的参数传递</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h5 id="在”flask全局变量一“，时，我讲了采用session-“变量名”-，来定义全局变量，实现在视图间传递变量。现在用用另一名方法，用上下文的方法，采用g变量，来定义全局变量。比方法一要简单"><a href="#在”flask全局变量一“，时，我讲了采用session-“变量名”-，来定义全局变量，实现在视图间传递变量。现在用用另一名方法，用上下文的方法，采用g变量，来定义全局变量。比方法一要简单" class="headerlink" title="在”flask全局变量一“，时，我讲了采用session[“变量名”]，来定义全局变量，实现在视图间传递变量。现在用用另一名方法，用上下文的方法，采用g变量，来定义全局变量。比方法一要简单"></a>在”flask全局变量一“，时，我讲了采用session[“变量名”]，来定义全局变量，实现在视图间传递变量。现在用用另一名方法，用上下文的方法，采用g变量，来定义全局变量。比方法一要简单</h5><h5 id="有几个上下文装饰器"><a href="#有几个上下文装饰器" class="headerlink" title="有几个上下文装饰器"></a>有几个上下文装饰器</h5><table>
<thead>
<tr>
<th>装饰器名</th>
<th>方式</th>
</tr>
</thead>
<tbody><tr>
<td>@app.before_request</td>
<td>函数会在请求处理之前被调用</td>
</tr>
<tr>
<td>@app.after_request</td>
<td>函数会在请求处理完成后才被调用</td>
</tr>
<tr>
<td>@app.teardown_request</td>
<td>函数会在请求处理完成后才被调用</td>
</tr>
</tbody></table>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> flask <span class="keyword">import</span> Flask</span><br><span class="line"><span class="keyword">from</span> flask <span class="keyword">import</span> g, request</span><br><span class="line"></span><br><span class="line">app=Flask(__name__)</span><br><span class="line"></span><br><span class="line"><span class="meta">@app.before_request</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">span_num_init</span>():</span></span><br><span class="line">	g.start_num = <span class="number">0</span> <span class="comment"># 定义g变量</span></span><br><span class="line">	g.span_mum = <span class="number">5</span> <span class="comment"># 定义g变量</span></span><br><span class="line"></span><br><span class="line"><span class="meta">@app.route(<span class="params"><span class="string">&quot;/fun1&quot;</span></span>)</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">fun1</span>():</span></span><br><span class="line">    g.start_num=<span class="number">9</span></span><br><span class="line">    g.span_num=<span class="number">16</span></span><br><span class="line"></span><br><span class="line"><span class="meta">@app.route(<span class="params"><span class="string">&quot;/fun2&quot;</span></span>)</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">fun2</span>():</span></span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;start_num=&quot;</span>,g.start_num) <span class="comment"># 此处start_num又变为0</span></span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;span_num=&quot;</span>,g.span_num]) <span class="comment"># 此处start_num又变为5</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

      
    </div>
    <footer class="article-footer">
      
        <a data-url="https://gitee.com/superigbt_superigbt/superigbt_superigbt/2021/11/02/flask-global-var3/" data-id="cl7zulc6w0027eiq578m10epc" class="article-share-link" data-share="baidu" data-title="flask全局变量三，视图间的参数传递">分享到</a>
      

      

      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/flask%E6%A1%86%E6%9E%B6/" rel="tag">flask框架</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%BB%BA%E7%AB%99/" rel="tag">建站</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-flask-global-var2" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2021/11/01/flask-global-var2/" class="article-date">
  <time datetime="2021-11-01T08:00:00.000Z" itemprop="datePublished">2021-11-01</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/python%E5%AD%A6%E4%B9%A0/">python学习</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2021/11/01/flask-global-var2/">flask全局变量二，自定义上下文参数</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h5 id="如果我要在模板中一个多选菜单的项目是个变量。那么要每个视图函数读一次变量，再发送到模版中去。比如："><a href="#如果我要在模板中一个多选菜单的项目是个变量。那么要每个视图函数读一次变量，再发送到模版中去。比如：" class="headerlink" title="如果我要在模板中一个多选菜单的项目是个变量。那么要每个视图函数读一次变量，再发送到模版中去。比如："></a>如果我要在模板中一个多选菜单的项目是个变量。那么要每个视图函数读一次变量，再发送到模版中去。比如：</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">get_option_item</span>():</span></span><br><span class="line">    item = [<span class="string">&quot;项目1&quot;</span>，<span class="string">&quot;项目2&quot;</span>，<span class="string">&quot;项目3&quot;</span>，<span class="string">&quot;项目4&quot;</span>，<span class="string">&quot;项目5&quot;</span>，<span class="string">&quot;项目6&quot;</span>，<span class="string">&quot;项目7&quot;</span>，]</span><br><span class="line">    <span class="keyword">return</span> item</span><br><span class="line"><span class="comment">#视图1</span></span><br><span class="line"><span class="meta">@app.route(<span class="params">/index1</span>)</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">index1</span>():</span></span><br><span class="line">    item=get_option_item()</span><br><span class="line">    <span class="keyword">return</span> render_template(<span class="string">&quot;index1.html&quot;</span>, item=itme)</span><br><span class="line">....</span><br><span class="line"><span class="comment">#视图n</span></span><br><span class="line"><span class="meta">@app.route(<span class="params">/index_n</span>)</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">index_n</span>():</span></span><br><span class="line">    item=get_option_item()</span><br><span class="line">    <span class="keyword">return</span> render_template(<span class="string">&quot;indexn.html&quot;</span>, item=itme)</span><br></pre></td></tr></table></figure>
<p>在模板中</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">select</span>&gt;</span></span><br><span class="line">    &#123;% for select_i in item %&#125;</span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span>&gt;</span> select_i <span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">    &#123;% endfor %&#125;</span><br><span class="line"><span class="tag">&lt;/<span class="name">select</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h5 id="每个视图要读一次很烦，那么采用上下文变量的方式就很好的解决了这个问题。修改一下python代码"><a href="#每个视图要读一次很烦，那么采用上下文变量的方式就很好的解决了这个问题。修改一下python代码" class="headerlink" title="每个视图要读一次很烦，那么采用上下文变量的方式就很好的解决了这个问题。修改一下python代码"></a>每个视图要读一次很烦，那么采用上下文变量的方式就很好的解决了这个问题。修改一下python代码</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># current_app对象是一个定义在应用上下文中的代理</span></span><br><span class="line"><span class="keyword">from</span> flask <span class="keyword">import</span> current_app</span><br><span class="line">app=Flask(__name__)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 函数用@app.context_processor装饰器修饰，它是一个上下文处理器，它的作用是在模板被渲染前运行其所修饰的函数，并将函数返回的字典导入到模板上下文环境中，与模板上下文合并。</span></span><br><span class="line"><span class="meta">@app.context_processor</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">get_option_item</span>():</span></span><br><span class="line">    item = [<span class="string">&quot;项目1&quot;</span>，<span class="string">&quot;项目2&quot;</span>，<span class="string">&quot;项目3&quot;</span>，<span class="string">&quot;项目4&quot;</span>，<span class="string">&quot;项目5&quot;</span>，<span class="string">&quot;项目6&quot;</span>，<span class="string">&quot;项目7&quot;</span>，]</span><br><span class="line">    <span class="keyword">return</span> <span class="built_in">dict</span>(item=item) <span class="comment">#注意是字典</span></span><br><span class="line"><span class="comment"># 视图函数不用再调用了</span></span><br><span class="line"><span class="comment">#视图n</span></span><br><span class="line"><span class="meta">@app.route(<span class="params">/index_n</span>)</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">index_n</span>():</span></span><br><span class="line">    <span class="comment"># item=get_option_item()</span></span><br><span class="line">    <span class="keyword">return</span> render_template(<span class="string">&quot;indexn.html&quot;</span>)</span><br></pre></td></tr></table></figure>
<h5 id="模板不用改变，直接就可用了。"><a href="#模板不用改变，直接就可用了。" class="headerlink" title="模板不用改变，直接就可用了。"></a>模板不用改变，直接就可用了。</h5>
      
    </div>
    <footer class="article-footer">
      
        <a data-url="https://gitee.com/superigbt_superigbt/superigbt_superigbt/2021/11/01/flask-global-var2/" data-id="cl7zulc6v0026eiq501g85xi2" class="article-share-link" data-share="baidu" data-title="flask全局变量二，自定义上下文参数">分享到</a>
      

      

      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/flask%E6%A1%86%E6%9E%B6/" rel="tag">flask框架</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%BB%BA%E7%AB%99/" rel="tag">建站</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-strealit-multiple-widgets" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2021/10/26/strealit-multiple-widgets/" class="article-date">
  <time datetime="2021-10-26T02:00:00.000Z" itemprop="datePublished">2021-10-26</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/python%E5%AD%A6%E4%B9%A0/">python学习</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2021/10/26/strealit-multiple-widgets/">streamlit学习笔记五-----多个小部件分组</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="默认情况下，每次用户与您的streamlit应用（表单）交互时，Streamlit-都会重新运行您的脚本。然而，有时在实际重新运行脚本之前等待一组相关的小部件（表单项）被填充完后，再执行更好，这里st-form-诞生了。"><a href="#默认情况下，每次用户与您的streamlit应用（表单）交互时，Streamlit-都会重新运行您的脚本。然而，有时在实际重新运行脚本之前等待一组相关的小部件（表单项）被填充完后，再执行更好，这里st-form-诞生了。" class="headerlink" title="默认情况下，每次用户与您的streamlit应用（表单）交互时，Streamlit 都会重新运行您的脚本。然而，有时在实际重新运行脚本之前等待一组相关的小部件（表单项）被填充完后，再执行更好，这里st.form()诞生了。"></a>默认情况下，每次用户与您的streamlit应用（表单）交互时，Streamlit 都会重新运行您的脚本。然而，有时在实际重新运行脚本之前等待一组相关的小部件（表单项）被填充完后，再执行更好，这里st.form()诞生了。</h3><h4 id="格式"><a href="#格式" class="headerlink" title="格式"></a>格式</h4><p>st.form(key: str, clear_on_submit: bool = False)<br>key: 字符串，表示这个表单的标识<br>clear_on_submit：布而值，如果为 True，则在用户按下提交按钮后，表单内的所有小部件都将重置为其默认值。</p>
<h5 id="一-with用法"><a href="#一-with用法" class="headerlink" title="一 with用法"></a>一 with用法</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">with</span> st.form(<span class="string">&quot;my_form&quot;</span>):</span><br><span class="line">    st.write(<span class="string">&quot;Inside the form&quot;</span>)</span><br><span class="line">    slider_val = st.slider(<span class="string">&quot;Form slider&quot;</span>)</span><br><span class="line">    checkbox_val = st.checkbox(<span class="string">&quot;Form checkbox&quot;</span>)</span><br><span class="line"></span><br><span class="line">    <span class="comment"># 每一个form必须有一个 submit 按钮.</span></span><br><span class="line">    submitted = st.form_submit_button(<span class="string">&quot;Submit&quot;</span>)</span><br><span class="line">    <span class="keyword">if</span> submitted:</span><br><span class="line">        st.write(<span class="string">&quot;slider&quot;</span>, slider_val, <span class="string">&quot;checkbox&quot;</span>, checkbox_val)</span><br><span class="line"></span><br><span class="line">st.write(<span class="string">&quot;己通退了表单j&quot;</span>)</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h5 id="二-指名用法"><a href="#二-指名用法" class="headerlink" title="二 指名用法"></a>二 指名用法</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">form23 = st.form(<span class="string">&quot;my_form&quot;</span>)</span><br><span class="line">form23.slider(<span class="string">&quot;Inside the form&quot;</span>)</span><br><span class="line">st.slider(<span class="string">&quot;在此表单外面了&quot;</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 增加一个submit按钮到此表单:</span></span><br><span class="line">form23.form_submit_button(<span class="string">&quot;Submit&quot;</span>)</span><br><span class="line"></span><br></pre></td></tr></table></figure>
      
    </div>
    <footer class="article-footer">
      
        <a data-url="https://gitee.com/superigbt_superigbt/superigbt_superigbt/2021/10/26/strealit-multiple-widgets/" data-id="cl7zulc7i003heiq54p991795" class="article-share-link" data-share="baidu" data-title="streamlit学习笔记五-----多个小部件分组">分享到</a>
      

      

      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/streamlit-%E6%A1%86%E6%9E%B6/" rel="tag">streamlit 框架</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/" rel="tag">机器学习</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-flask-form3" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2021/10/06/flask-form3/" class="article-date">
  <time datetime="2021-10-06T09:19:00.000Z" itemprop="datePublished">2021-10-06</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/python%E5%AD%A6%E4%B9%A0/">python学习</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2021/10/06/flask-form3/">flask 的form学习之三，一个小form</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">MockCreate</span>(<span class="params">Form</span>):</span></span><br><span class="line">    user_email = StringField(<span class="string">&quot;email address&quot;</span>,[validators.Email()])</span><br><span class="line">    api = StringField(<span class="string">&quot;api&quot;</span>,[Required()])</span><br><span class="line">    submit = SubmitField(<span class="string">&quot;Submit&quot;</span>)</span><br><span class="line">    code = IntegerField(<span class="string">&quot;code example: 200&quot;</span>,[Required()])</span><br><span class="line">    alias = StringField(<span class="string">&quot;alias for api&quot;</span>)</span><br><span class="line">    data = TextAreaField(<span class="string">&quot;json format&quot;</span>,[Required()])</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="meta">@app.route(<span class="params"><span class="string">&quot;/mockservice&quot;</span>,methods=[<span class="string">&#x27;GET&#x27;</span>,<span class="string">&#x27;POST&#x27;</span>]</span>)</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">MockController</span>():</span></span><br><span class="line">    form = MockCreate()</span><br><span class="line">    code = form[<span class="string">&#x27;code&#x27;</span>]</span><br><span class="line">    api = form[<span class="string">&#x27;api&#x27;</span>]</span><br><span class="line">    <span class="keyword">return</span> render_template(<span class="string">&quot;testf.html&quot;</span>,api=api,data=code)</span><br></pre></td></tr></table></figure>
      
    </div>
    <footer class="article-footer">
      
        <a data-url="https://gitee.com/superigbt_superigbt/superigbt_superigbt/2021/10/06/flask-form3/" data-id="cl7zulc6n001zeiq5bxrlglll" class="article-share-link" data-share="baidu" data-title="flask 的form学习之三，一个小form">分享到</a>
      

      

      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/flask%E6%A1%86%E6%9E%B6/" rel="tag">flask框架</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%BB%BA%E7%AB%99/" rel="tag">建站</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-flask-global-var1" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2021/10/05/flask-global-var1/" class="article-date">
  <time datetime="2021-10-05T09:19:00.000Z" itemprop="datePublished">2021-10-05</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/python%E5%AD%A6%E4%B9%A0/">python学习</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2021/10/05/flask-global-var1/">flask全局变量一，视图间的参数传递</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="提出的问题："><a href="#提出的问题：" class="headerlink" title="提出的问题："></a>提出的问题：</h2><h4 id="flask视图间如何传递变量呢？开始我用的全局变量，如下"><a href="#flask视图间如何传递变量呢？开始我用的全局变量，如下" class="headerlink" title="flask视图间如何传递变量呢？开始我用的全局变量，如下"></a>flask视图间如何传递变量呢？开始我用的全局变量，如下</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> flask <span class="keyword">import</span> Flask,request,render_template</span><br><span class="line"></span><br><span class="line">app=Flask(__name__)</span><br><span class="line"></span><br><span class="line">app.secret_key = <span class="string">&#x27;就得是要一个key&#x27;</span>   <span class="comment"># 必须有</span></span><br><span class="line">app.config[<span class="string">&#x27;SESSION_TYPE&#x27;</span>] = <span class="string">&#x27;filesystem&#x27;</span> <span class="comment"># 必须有</span></span><br><span class="line"></span><br><span class="line">start_num=<span class="number">0</span></span><br><span class="line">span_num=<span class="number">5</span></span><br><span class="line"></span><br><span class="line"><span class="meta">@app.route(<span class="params"><span class="string">&quot;/fun1&quot;</span></span>)</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">fun1</span>():</span></span><br><span class="line">    start_num=<span class="number">9</span></span><br><span class="line">    span_num=<span class="number">16</span></span><br><span class="line"></span><br><span class="line"><span class="meta">@app.route(<span class="params"><span class="string">&quot;/fun2&quot;</span></span>)</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">fun2</span>():</span></span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;start_num=&quot;</span>,start_num) <span class="comment">#此处start_num又变为0</span></span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;span_num=&quot;</span>,span_num]) <span class="comment">#此处start_num又变为5</span></span><br></pre></td></tr></table></figure>
<p>在执行视图fun2时, session[“start_num”]与session[“span_num”]的值又变为初始值了。<br>咋整呢？</p>
<h4 id="网上找到一种办法是-session法。修改代码如下："><a href="#网上找到一种办法是-session法。修改代码如下：" class="headerlink" title="网上找到一种办法是 session法。修改代码如下："></a>网上找到一种办法是 session法。修改代码如下：</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> flask <span class="keyword">import</span> Flask,request,render_template</span><br><span class="line"><span class="keyword">from</span> flask <span class="keyword">import</span> session</span><br><span class="line"></span><br><span class="line">app=Flask(__name__)</span><br><span class="line"></span><br><span class="line">app.secret_key = <span class="string">&#x27;我的key&#x27;</span></span><br><span class="line">app.config[<span class="string">&#x27;SESSION_TYPE&#x27;</span>] = <span class="string">&#x27;filesystem&#x27;</span></span><br><span class="line"></span><br><span class="line">session[<span class="string">&quot;start_num&quot;</span>]=<span class="number">0</span></span><br><span class="line">session[<span class="string">&quot;span_num&quot;</span>]=<span class="number">5</span></span><br><span class="line"></span><br><span class="line"><span class="meta">@app.route(<span class="params"><span class="string">&quot;/fun1&quot;</span></span>)</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">fun1</span>():</span></span><br><span class="line">    session[<span class="string">&quot;start_num&quot;</span>]=<span class="number">9</span></span><br><span class="line">    session[<span class="string">&quot;span_num&quot;</span>]=<span class="number">16</span></span><br><span class="line"></span><br><span class="line"><span class="meta">@app.route(<span class="params"><span class="string">&quot;/fun2&quot;</span></span>)</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">fun2</span>():</span></span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;session[&quot;</span>start_num<span class="string">&quot;]&quot;</span>,session[<span class="string">&quot;start_num&quot;</span>]) <span class="comment">#此处session[&quot;start_num&quot;]又变为9</span></span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;session[&quot;</span>span_num<span class="string">&quot;]&quot;</span>,session[<span class="string">&quot;span_num&quot;</span>]) <span class="comment">#此处session[&quot;start_num&quot;]又变为16</span></span><br></pre></td></tr></table></figure>

<h5 id="还有一种办法就是把两个临时值传到数据库，或保存为json数据，存入文件中，程序不难，但是如果参数频繁改变的话，要反复读写文件就不好玩了。"><a href="#还有一种办法就是把两个临时值传到数据库，或保存为json数据，存入文件中，程序不难，但是如果参数频繁改变的话，要反复读写文件就不好玩了。" class="headerlink" title="还有一种办法就是把两个临时值传到数据库，或保存为json数据，存入文件中，程序不难，但是如果参数频繁改变的话，要反复读写文件就不好玩了。"></a>还有一种办法就是把两个临时值传到数据库，或保存为json数据，存入文件中，程序不难，但是如果参数频繁改变的话，要反复读写文件就不好玩了。</h5>
      
    </div>
    <footer class="article-footer">
      
        <a data-url="https://gitee.com/superigbt_superigbt/superigbt_superigbt/2021/10/05/flask-global-var1/" data-id="cl7zulc6r0021eiq540z55rnx" class="article-share-link" data-share="baidu" data-title="flask全局变量一，视图间的参数传递">分享到</a>
      

      

      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/flask%E6%A1%86%E6%9E%B6/" rel="tag">flask框架</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%BB%BA%E7%AB%99/" rel="tag">建站</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-flask-form2" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2021/10/05/flask-form2/" class="article-date">
  <time datetime="2021-10-05T06:19:00.000Z" itemprop="datePublished">2021-10-05</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/python%E5%AD%A6%E4%B9%A0/">python学习</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2021/10/05/flask-form2/">flask 的form学习之二，Flask-WTF</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="使用-Flask-WTF的好处是直接在python中定义表单中的字段，比较直观"><a href="#使用-Flask-WTF的好处是直接在python中定义表单中的字段，比较直观" class="headerlink" title="使用 Flask-WTF的好处是直接在python中定义表单中的字段，比较直观"></a>使用 Flask-WTF的好处是直接在python中定义表单中的字段，比较直观</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ pip install flask-WTF</span><br></pre></td></tr></table></figure>
<h4 id="一-WTForms支持的全部HTML标准字段"><a href="#一-WTForms支持的全部HTML标准字段" class="headerlink" title="一. WTForms支持的全部HTML标准字段"></a>一. WTForms支持的全部HTML标准字段</h4><table>
<thead>
<tr>
<th>字段对象</th>
<th>说明</th>
<th>相当于html的语句</th>
</tr>
</thead>
<tbody><tr>
<td>StringField</td>
<td>文本字段</td>
<td><input type="text"></td>
</tr>
<tr>
<td>TextAreaField</td>
<td>多行文本字段</td>
<td></td>
</tr>
<tr>
<td>PasswordField</td>
<td>密码字段</td>
<td><input type="checkbox"></td>
</tr>
<tr>
<td>HiddenField</td>
<td>隐藏文件字段</td>
<td></td>
</tr>
<tr>
<td>DateField</td>
<td>文本字段，值为datetime.date文本格式</td>
<td></td>
</tr>
<tr>
<td>DateTimeField</td>
<td>文本字段，值为datetime.datetime文本格式</td>
<td></td>
</tr>
<tr>
<td>IntegerField</td>
<td>文本字段，值为整数</td>
<td></td>
</tr>
<tr>
<td>DecimalField</td>
<td>文本字段，值为decimal.Decimal数</td>
<td></td>
</tr>
<tr>
<td>FloatField</td>
<td>文本字段，值为浮点数</td>
<td></td>
</tr>
<tr>
<td>BooleanField</td>
<td>复选框，值为True或False</td>
<td>&lt;input type=”radio”</td>
</tr>
<tr>
<td>RadioField</td>
<td>一组单选框</td>
<td></td>
</tr>
<tr>
<td>SelectField</td>
<td>下接列表</td>
<td></td>
</tr>
<tr>
<td>SelecMultipleField</td>
<td>可选择多个值的下接列表</td>
<td></td>
</tr>
<tr>
<td>FileField</td>
<td>文件上传</td>
<td></td>
</tr>
<tr>
<td>SubmitField</td>
<td>表单提交按钮</td>
<td><input type="submit"></td>
</tr>
<tr>
<td>FormField</td>
<td>把表单做为字段嵌入另一个表单</td>
<td></td>
</tr>
<tr>
<td>FieldList</td>
<td>一组指定类型的字段</td>
<td></td>
</tr>
</tbody></table>
<h4 id="二-python代码"><a href="#二-python代码" class="headerlink" title="二 python代码"></a>二 python代码</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> flask <span class="keyword">import</span> Flask</span><br><span class="line"><span class="keyword">from</span> flask <span class="keyword">import</span> render_template</span><br><span class="line"><span class="keyword">from</span> flask_wtf <span class="keyword">import</span> FlaskForm</span><br><span class="line"><span class="keyword">from</span> wtforms.fields <span class="keyword">import</span> (StringField, PasswordField, DateField, BooleanField,</span><br><span class="line">                            SelectField, SelectMultipleField, TextAreaField,</span><br><span class="line">                            RadioField, IntegerField, DecimalField, SubmitField)</span><br><span class="line"><span class="keyword">from</span> wtforms.validators <span class="keyword">import</span> DataRequired, InputRequired, Length, Email, EqualTo, NumberRange</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">app = Flask(__name__)</span><br><span class="line">app.secret_key = <span class="string">&#x27;asdfs&#x27;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">WtfForm</span>(<span class="params">FlaskForm</span>):</span></span><br><span class="line">    <span class="comment"># StringField 文本输入框，必填，用户名长度为4到25之间，占位符</span></span><br><span class="line">    username = StringField(<span class="string">&#x27;用户名：&#x27;</span>, validators=[Length(<span class="built_in">min</span>=<span class="number">4</span>, <span class="built_in">max</span>=<span class="number">25</span>)], render_kw=&#123;<span class="string">&#x27;placeholder&#x27;</span>: <span class="string">&#x27;请输入用户名&#x27;</span>&#125;)</span><br><span class="line"></span><br><span class="line">    <span class="comment"># Email格式</span></span><br><span class="line">    email = StringField(<span class="string">&#x27;邮箱地址：&#x27;</span>, validators=[Email()], render_kw=&#123;<span class="string">&#x27;placeholder&#x27;</span>: <span class="string">&#x27;请输入邮箱地址&#x27;</span>&#125;)</span><br><span class="line"></span><br><span class="line">    <span class="comment"># PasswordField，密码输入框，必填</span></span><br><span class="line">    password = PasswordField(<span class="string">&#x27;密码：&#x27;</span>, validators=[DataRequired()], render_kw=&#123;<span class="string">&#x27;placeholder&#x27;</span>: <span class="string">&#x27;请输入密码&#x27;</span>&#125;)</span><br><span class="line"></span><br><span class="line">    <span class="comment"># 确认密码，必须和密码一致</span></span><br><span class="line">    password2 = PasswordField(<span class="string">&#x27;确认密码：&#x27;</span>, validators=[InputRequired(), EqualTo(<span class="string">&#x27;password&#x27;</span>, <span class="string">&#x27;两次密码要一致&#x27;</span>)])</span><br><span class="line"></span><br><span class="line">    <span class="comment"># IntegerField，文本输入框，必须输入整型数值，范围在16到70之间</span></span><br><span class="line">    age = IntegerField(<span class="string">&#x27;年龄：&#x27;</span>, validators=[NumberRange(<span class="built_in">min</span>=<span class="number">16</span>, <span class="built_in">max</span>=<span class="number">70</span>)])</span><br><span class="line"></span><br><span class="line">    <span class="comment"># DecimalField，文本输入框，必须输入数值，显示时保留一位小数</span></span><br><span class="line">    height = DecimalField(<span class="string">&#x27;身高(cm):&#x27;</span>, places=<span class="number">1</span>)</span><br><span class="line"></span><br><span class="line">    <span class="comment"># DateField，文本输入框，必须输入是&quot;年-月-日&quot;格式的日期</span></span><br><span class="line">    birthday = DateField(<span class="string">&#x27;出生日期：&#x27;</span>, <span class="built_in">format</span>=<span class="string">&#x27;%Y-%m-%d&#x27;</span>)</span><br><span class="line"></span><br><span class="line">    <span class="comment"># RadioField，单选框，choices里的内容会在ul标签里，里面每个项是(值，显示名)对</span></span><br><span class="line">    gender = RadioField(<span class="string">&#x27;性别：&#x27;</span>, choices=[(<span class="string">&#x27;0&#x27;</span>, <span class="string">&#x27;男&#x27;</span>), (<span class="string">&#x27;1&#x27;</span>, <span class="string">&#x27;女&#x27;</span>)], validators=[DataRequired()])</span><br><span class="line"></span><br><span class="line">    <span class="comment"># SelectField，下拉单选框，choices里的内容会在Option里，里面每个项是(值，显示名)对</span></span><br><span class="line">    job = SelectField(<span class="string">&#x27;职业：&#x27;</span>, choices=[</span><br><span class="line">        (<span class="string">&#x27;teacher&#x27;</span>, <span class="string">&#x27;教师&#x27;</span>),</span><br><span class="line">        (<span class="string">&#x27;doctor&#x27;</span>, <span class="string">&#x27;医生&#x27;</span>),</span><br><span class="line">        (<span class="string">&#x27;engineer&#x27;</span>, <span class="string">&#x27;工程师&#x27;</span>),</span><br><span class="line">        (<span class="string">&#x27;lawyer&#x27;</span>, <span class="string">&#x27;律师&#x27;</span>)</span><br><span class="line">    ])</span><br><span class="line"></span><br><span class="line">    <span class="comment"># Select类型，多选框，choices里的内容会在Option里，里面每个项是(值，显示名)对</span></span><br><span class="line">    hobby = SelectMultipleField(<span class="string">&#x27;爱好：&#x27;</span>, choices=[</span><br><span class="line">        (<span class="string">&#x27;0&#x27;</span>, <span class="string">&#x27;吃饭&#x27;</span>),</span><br><span class="line">        (<span class="string">&#x27;1&#x27;</span>, <span class="string">&#x27;睡觉&#x27;</span>),</span><br><span class="line">        (<span class="string">&#x27;2&#x27;</span>, <span class="string">&#x27;敲代码&#x27;</span>)</span><br><span class="line">    ])</span><br><span class="line"></span><br><span class="line">    <span class="comment"># TextAreaField，段落输入框</span></span><br><span class="line">    description = TextAreaField(<span class="string">&#x27;自我介绍：&#x27;</span>, validators=[InputRequired()], render_kw=&#123;<span class="string">&#x27;placeholder&#x27;</span>: <span class="string">&#x27;例：小明，18岁，未婚找女友&#x27;</span>&#125;)</span><br><span class="line"></span><br><span class="line">    <span class="comment"># BooleanField，Checkbox类型，加上default=&#x27;checked&#x27;即默认是选上的</span></span><br><span class="line">    accept_terms = BooleanField(<span class="string">&#x27;是否接受上述条款&#x27;</span>, default=<span class="string">&#x27;checked&#x27;</span>, validators=[DataRequired()])</span><br><span class="line"></span><br><span class="line">    <span class="comment"># SubmitField，Submit按钮</span></span><br><span class="line">    submit = SubmitField(<span class="string">&#x27;提交&#x27;</span>)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="meta">@app.route(<span class="params"><span class="string">&#x27;/&#x27;</span>, methods=[<span class="string">&#x27;POST&#x27;</span>, <span class="string">&#x27;GET&#x27;</span>]</span>)</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">index</span>():</span></span><br><span class="line">    form = WtfForm()</span><br><span class="line">    <span class="keyword">return</span> render_template(<span class="string">&#x27;wtf.html&#x27;</span>, form=form)</span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">&quot;__main__&quot;</span>:</span><br><span class="line">    app.run(debug=<span class="literal">True</span>)</span><br></pre></td></tr></table></figure>
<h4 id="三-html代码"><a href="#三-html代码" class="headerlink" title="三. html代码"></a>三. html代码</h4><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">&quot;en&quot;</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">&quot;UTF-8&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>Title<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">form</span> <span class="attr">action</span>=<span class="string">&quot;&quot;</span>&gt;</span></span><br><span class="line">    &#123;&#123; form.csrf_token &#125;&#125;</span><br><span class="line">    &#123;&#123; form.username.label &#125;&#125;&#123;&#123; form.username &#125;&#125;</span><br><span class="line">    <span class="tag">&lt;<span class="name">br</span>&gt;</span></span><br><span class="line">    &#123;&#123; form.email.label &#125;&#125;&#123;&#123; form.email &#125;&#125;</span><br><span class="line">    <span class="tag">&lt;<span class="name">br</span>&gt;</span></span><br><span class="line">    &#123;&#123; form.password.label &#125;&#125;&#123;&#123; form.password &#125;&#125;</span><br><span class="line">    <span class="tag">&lt;<span class="name">br</span>&gt;</span></span><br><span class="line">    &#123;&#123; form.password2.label &#125;&#125;&#123;&#123; form.password2 &#125;&#125;</span><br><span class="line">    <span class="tag">&lt;<span class="name">br</span>&gt;</span></span><br><span class="line">    &#123;&#123; form.age.label &#125;&#125;&#123;&#123; form.age &#125;&#125;</span><br><span class="line">    <span class="tag">&lt;<span class="name">br</span>&gt;</span></span><br><span class="line">    &#123;&#123; form.height.label &#125;&#125;&#123;&#123; form.height &#125;&#125;</span><br><span class="line">    <span class="tag">&lt;<span class="name">br</span>&gt;</span></span><br><span class="line">    &#123;&#123; form.birthday.label &#125;&#125;&#123;&#123; form.birthday &#125;&#125;</span><br><span class="line">    <span class="tag">&lt;<span class="name">hr</span>&gt;</span></span><br><span class="line">    &#123;&#123; form.gender.label &#125;&#125;&#123;&#123; form.gender &#125;&#125;</span><br><span class="line">    <span class="tag">&lt;<span class="name">br</span>&gt;</span></span><br><span class="line">    &#123;&#123; form.job.label &#125;&#125;&#123;&#123; form.job &#125;&#125;</span><br><span class="line">    <span class="tag">&lt;<span class="name">br</span>&gt;</span></span><br><span class="line">    &#123;&#123; form.hobby.label &#125;&#125;&#123;&#123; form.hobby &#125;&#125;</span><br><span class="line">    <span class="tag">&lt;<span class="name">br</span>&gt;</span></span><br><span class="line">    &#123;&#123; form.description.label &#125;&#125;&#123;&#123; form.description &#125;&#125;</span><br><span class="line">    <span class="tag">&lt;<span class="name">br</span>&gt;</span></span><br><span class="line">    &#123;&#123; form.accept_terms.label &#125;&#125;&#123;&#123; form.accept_terms &#125;&#125;</span><br><span class="line">    <span class="tag">&lt;<span class="name">br</span>&gt;</span></span><br><span class="line">    &#123;&#123; form.submit &#125;&#125;</span><br><span class="line">    <span class="tag">&lt;<span class="name">br</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">form</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

      
    </div>
    <footer class="article-footer">
      
        <a data-url="https://gitee.com/superigbt_superigbt/superigbt_superigbt/2021/10/05/flask-form2/" data-id="cl7zulc6m001veiq5di5a2u7q" class="article-share-link" data-share="baidu" data-title="flask 的form学习之二，Flask-WTF">分享到</a>
      

      

      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/flask%E6%A1%86%E6%9E%B6/" rel="tag">flask框架</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%BB%BA%E7%AB%99/" rel="tag">建站</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-flask-form1" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2021/10/04/flask-form1/" class="article-date">
  <time datetime="2021-10-04T09:19:00.000Z" itemprop="datePublished">2021-10-04</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/python%E5%AD%A6%E4%B9%A0/">python学习</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2021/10/04/flask-form1/">flask 的form学习之一，传统form</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h4 id="传统的方法与php一样，先在html里建立form-并用action指向视图函数处理，并用POST方法传递参数。不多说，代码说明。"><a href="#传统的方法与php一样，先在html里建立form-并用action指向视图函数处理，并用POST方法传递参数。不多说，代码说明。" class="headerlink" title="传统的方法与php一样，先在html里建立form,并用action指向视图函数处理，并用POST方法传递参数。不多说，代码说明。"></a>传统的方法与php一样，先在html里建立form,并用action指向视图函数处理，并用POST方法传递参数。不多说，代码说明。</h4><h5 id="一-html文件-form-html"><a href="#一-html文件-form-html" class="headerlink" title="一. html文件 form.html"></a>一. html文件 form.html</h5><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">&quot;zh&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">&quot;UTF-8&quot;</span> &gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">title</span>&gt;</span>表单示便<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">form</span> <span class="attr">action</span>=<span class="string">&quot;regist&quot;</span>,<span class="attr">method</span>=<span class="string">&quot;POST&quot;</span> &gt;</span></span><br><span class="line">            用户名:<span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span>,<span class="attr">name</span>=<span class="string">&quot;username&quot;</span>&gt;</span><span class="tag">&lt;<span class="name">br</span>&gt;</span></span><br><span class="line">            密码:<span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span>,<span class="attr">name</span>=<span class="string">&quot;pawd&quot;</span>&gt;</span><span class="tag">&lt;<span class="name">br</span>&gt;</span></span><br><span class="line">            再次密码：:<span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span>,<span class="attr">name</span>=<span class="string">&quot;re-pawd&quot;</span>&gt;</span><span class="tag">&lt;<span class="name">br</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;submit&quot;</span>,<span class="attr">value</span>=<span class="string">&quot;注册&quot;</span>&gt;</span><span class="tag">&lt;<span class="name">br</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">form</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h5 id="二-python代码中的视图函数"><a href="#二-python代码中的视图函数" class="headerlink" title="二. python代码中的视图函数"></a>二. python代码中的视图函数</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> flask <span class="keyword">import</span> Flask,request,render_template</span><br><span class="line"></span><br><span class="line">app=Flask(__name__)</span><br><span class="line"></span><br><span class="line"><span class="meta">@app.route(<span class="params">/</span>)</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">index</span>():</span></span><br><span class="line">    <span class="keyword">return</span> render_template(<span class="string">&quot;index.html&quot;</span>)</span><br><span class="line"></span><br><span class="line"><span class="meta">@app.route(<span class="params"><span class="string">&quot;regist&quot;</span></span>)</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">regist</span>():</span></span><br><span class="line">    <span class="keyword">if</span> request.method==<span class="string">&quot;GET&quot;</span>:</span><br><span class="line">        <span class="keyword">return</span> render_template(<span class="string">&quot;regist.html&quot;</span>) <span class="comment"># 没有输入的样子就是这个。</span></span><br><span class="line">    <span class="keyword">if</span> request.methom==<span class="string">&quot;POST&quot;</span>:</span><br><span class="line">        uname=request.form.get(<span class="string">&quot;username&quot;</span>)</span><br><span class="line">        password=request.form.get(<span class="string">&quot;pawd&quot;</span>)</span><br><span class="line">        re_password=request.form.get(<span class="string">&quot;re-pawd&quot;</span>)</span><br><span class="line">    <span class="comment">#下面添加处理语句</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__==<span class="string">&quot;__main__&quot;</span>:</span><br><span class="line">    app.debug=<span class="literal">True</span></span><br><span class="line">    app.run(host = <span class="string">&#x27;127.0.0.1&#x27;</span>,port = <span class="number">8080</span> )</span><br><span class="line"></span><br></pre></td></tr></table></figure>
      
    </div>
    <footer class="article-footer">
      
        <a data-url="https://gitee.com/superigbt_superigbt/superigbt_superigbt/2021/10/04/flask-form1/" data-id="cl7zulc6l001ueiq5aj475xl9" class="article-share-link" data-share="baidu" data-title="flask 的form学习之一，传统form">分享到</a>
      

      

      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/flask%E6%A1%86%E6%9E%B6/" rel="tag">flask框架</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%BB%BA%E7%AB%99/" rel="tag">建站</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-flask-luckysheet" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2021/09/11/flask-luckysheet/" class="article-date">
  <time datetime="2021-09-11T09:19:00.000Z" itemprop="datePublished">2021-09-11</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/python%E5%AD%A6%E4%B9%A0/">python学习</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2021/09/11/flask-luckysheet/">flask打开Excel文件，并传给luckysheet显示</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="flask是个很好的网站框架，luckysheet的是一个很好的采用JS编写的表格框架，由于我一直采用flask，没有学习过javascript，所以想利用方便的lucksheet，如何结合呢？"><a href="#flask是个很好的网站框架，luckysheet的是一个很好的采用JS编写的表格框架，由于我一直采用flask，没有学习过javascript，所以想利用方便的lucksheet，如何结合呢？" class="headerlink" title="flask是个很好的网站框架，luckysheet的是一个很好的采用JS编写的表格框架，由于我一直采用flask，没有学习过javascript，所以想利用方便的lucksheet，如何结合呢？"></a>flask是个很好的网站框架，luckysheet的是一个很好的采用JS编写的表格框架，由于我一直采用flask，没有学习过javascript，所以想利用方便的lucksheet，如何结合呢？</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#coding:utf8</span></span><br><span class="line"><span class="keyword">from</span> flask <span class="keyword">import</span> Flask</span><br><span class="line"><span class="keyword">from</span> flask <span class="keyword">import</span> request,render_template</span><br><span class="line"><span class="keyword">import</span> pandas <span class="keyword">as</span> pd</span><br><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="comment"># from werkzeug import secure_filename</span></span><br><span class="line"><span class="keyword">import</span> os</span><br><span class="line"></span><br><span class="line">app=Flask(__name__)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 以下函数把一个excel表格读出，然后把数据转换成luckysheet的celldata，以便采用luckysheet显示在网页上</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">pands_to_luckysheet</span>(<span class="params">file_name</span>):</span></span><br><span class="line">	sheet_data=[] <span class="comment"># 定义一个空列表</span></span><br><span class="line"></span><br><span class="line">	data_f = pd.read_excel(file_name)</span><br><span class="line"></span><br><span class="line">	none_nan=(data_f.isnull()) | (data_f.apply(<span class="keyword">lambda</span> x: <span class="built_in">str</span>(x).isspace())) <span class="comment"># 找到所有的None</span></span><br><span class="line">	data_f=data_f[~none_nan] <span class="comment"># 把所有的None替换为nan</span></span><br><span class="line">	<span class="comment"># print(&quot;data_f2=&quot;,data_f)</span></span><br><span class="line">	data_f=data_f.fillna(<span class="string">&quot;&quot;</span>)  <span class="comment"># 把所有的nan替换为空字符</span></span><br><span class="line">	<span class="comment"># print(&quot;data_f3=&quot;,data_f)	</span></span><br><span class="line">	row=<span class="built_in">len</span>(data_f) <span class="comment"># 行数</span></span><br><span class="line">	col=<span class="built_in">len</span>(data_f.columns)  <span class="comment">#列数</span></span><br><span class="line">	<span class="comment"># 打算把数据转换为luckysheet的celldata数据</span></span><br><span class="line">	<span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(row):</span><br><span class="line">		<span class="keyword">for</span> j <span class="keyword">in</span> <span class="built_in">range</span>(col):</span><br><span class="line">			<span class="comment"># sheet_data[k]=[&#123;&quot;r&quot;:i,&quot;c&quot;:j,&quot;v&quot;:&#123;&quot;v&quot;:data_f.iloc[i,j]&#125;&#125;]</span></span><br><span class="line">			<span class="comment"># k=k+1</span></span><br><span class="line">			sheet_data.append(&#123;<span class="string">&quot;r&quot;</span>:i,<span class="string">&quot;c&quot;</span>:j,<span class="string">&quot;v&quot;</span>:&#123;<span class="string">&quot;v&quot;</span>:data_f.iloc[i,j],<span class="string">&quot;m&quot;</span>:data_f.iloc[i,j]&#125;&#125;) <span class="comment"># 添加列表项</span></span><br><span class="line">	<span class="keyword">return</span> sheet_data</span><br><span class="line">	<span class="comment"># print(&quot;测试luckckyshee数据转换&quot;)  </span></span><br><span class="line">	<span class="comment"># print(sheet_data)	</span></span><br><span class="line"></span><br><span class="line"><span class="meta">@app.route(<span class="params"><span class="string">&quot;/table_channel&quot;</span></span>)</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">table_channel</span>():</span></span><br><span class="line">	sheet_data=pands_to_luckysheet(<span class="string">&quot;/home/mywork/2021/汇总.xlsx&quot;</span>)</span><br><span class="line">	<span class="comment"># print(&quot;sheet_data=&quot;,sheet_data)</span></span><br><span class="line">	<span class="keyword">return</span> render_template(<span class="string">&quot;index.html&quot;</span> ,lucky_data=sheet_data)</span><br><span class="line"></span><br></pre></td></tr></table></figure>
      
    </div>
    <footer class="article-footer">
      
        <a data-url="https://gitee.com/superigbt_superigbt/superigbt_superigbt/2021/09/11/flask-luckysheet/" data-id="cl7zulc70002heiq58i3tepev" class="article-share-link" data-share="baidu" data-title="flask打开Excel文件，并传给luckysheet显示">分享到</a>
      

      

      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/flask%E6%A1%86%E6%9E%B6/" rel="tag">flask框架</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%BB%BA%E7%AB%99/" rel="tag">建站</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-streamlit-4" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2021/09/10/streamlit-4/" class="article-date">
  <time datetime="2021-09-10T02:00:00.000Z" itemprop="datePublished">2021-09-10</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/python%E5%AD%A6%E4%B9%A0/">python学习</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2021/09/10/streamlit-4/">streamlit学习笔记四-----暂称为组件吧</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h5 id="创建静态组件"><a href="#创建静态组件" class="headerlink" title="创建静态组件"></a>创建静态组件</h5><p>如果您创建 Streamlit 组件的目标仅仅是显示 HTML 代码或从 Python 可视化库中呈现图表，Streamlit 提供了两种方法来极大地简化流程：components.html() 和 components.iframe()。</p>
<ol>
<li>渲染一个 HTML 字符串用： <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">streamlit.components.v1.html(html, width=<span class="literal">None</span>, height=<span class="literal">None</span>, scrolling=<span class="literal">False</span>)</span><br></pre></td></tr></table></figure>

html (str) – 要嵌入 iframe 的 HTML 字符串。注意是字符串，如果是文件名，则会出错</li>
</ol>
<p>width (int) – 以 CSS 像素为单位的框架宽度。 默认为报告的默认元素宽度。</p>
<p>height (int) – 以 CSS 像素为单位的框架高度。 默认为 150。</p>
<p>scrolling (bool) – 如果为 True，则在内容大于 iframe 时显示滚动条。 否则，不显示滚动条。 默认为假。<br>例子：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> streamlit <span class="keyword">as</span> st</span><br><span class="line"><span class="keyword">import</span> streamlit.components.v1 <span class="keyword">as</span> components</span><br><span class="line"></span><br><span class="line"><span class="comment"># bootstrap 4 collapse example</span></span><br><span class="line"></span><br><span class="line">   html_data= <span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css&quot; integrity=&quot;sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm&quot; crossorigin=&quot;anonymous&quot;&gt;</span></span><br><span class="line"><span class="string">    &lt;script src=&quot;https://code.jquery.com/jquery-3.2.1.slim.min.js&quot; integrity=&quot;sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;</span></span><br><span class="line"><span class="string">    &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js&quot; integrity=&quot;sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;</span></span><br><span class="line"><span class="string">    &lt;div id=&quot;accordion&quot;&gt;</span></span><br><span class="line"><span class="string">      &lt;div class=&quot;card&quot;&gt;</span></span><br><span class="line"><span class="string">        &lt;div class=&quot;card-header&quot; id=&quot;headingOne&quot;&gt;</span></span><br><span class="line"><span class="string">          &lt;h5 class=&quot;mb-0&quot;&gt;</span></span><br><span class="line"><span class="string">            &lt;button class=&quot;btn btn-link&quot; data-toggle=&quot;collapse&quot; data-target=&quot;#collapseOne&quot; aria-expanded=&quot;true&quot; aria-controls=&quot;collapseOne&quot;&gt;</span></span><br><span class="line"><span class="string">            Collapsible Group Item #1</span></span><br><span class="line"><span class="string">            &lt;/button&gt;</span></span><br><span class="line"><span class="string">          &lt;/h5&gt;</span></span><br><span class="line"><span class="string">        &lt;/div&gt;</span></span><br><span class="line"><span class="string">        &lt;div id=&quot;collapseOne&quot; class=&quot;collapse show&quot; aria-labelledby=&quot;headingOne&quot; data-parent=&quot;#accordion&quot;&gt;</span></span><br><span class="line"><span class="string">          &lt;div class=&quot;card-body&quot;&gt;</span></span><br><span class="line"><span class="string">            Collapsible Group Item #1 content</span></span><br><span class="line"><span class="string">          &lt;/div&gt;</span></span><br><span class="line"><span class="string">        &lt;/div&gt;</span></span><br><span class="line"><span class="string">      &lt;/div&gt;</span></span><br><span class="line"><span class="string">      &lt;div class=&quot;card&quot;&gt;</span></span><br><span class="line"><span class="string">        &lt;div class=&quot;card-header&quot; id=&quot;headingTwo&quot;&gt;</span></span><br><span class="line"><span class="string">          &lt;h5 class=&quot;mb-0&quot;&gt;</span></span><br><span class="line"><span class="string">            &lt;button class=&quot;btn btn-link collapsed&quot; data-toggle=&quot;collapse&quot; data-target=&quot;#collapseTwo&quot; aria-expanded=&quot;false&quot; aria-controls=&quot;collapseTwo&quot;&gt;</span></span><br><span class="line"><span class="string">            Collapsible Group Item #2</span></span><br><span class="line"><span class="string">            &lt;/button&gt;</span></span><br><span class="line"><span class="string">          &lt;/h5&gt;</span></span><br><span class="line"><span class="string">        &lt;/div&gt;</span></span><br><span class="line"><span class="string">        &lt;div id=&quot;collapseTwo&quot; class=&quot;collapse&quot; aria-labelledby=&quot;headingTwo&quot; data-parent=&quot;#accordion&quot;&gt;</span></span><br><span class="line"><span class="string">          &lt;div class=&quot;card-body&quot;&gt;</span></span><br><span class="line"><span class="string">            Collapsible Group Item #2 content</span></span><br><span class="line"><span class="string">          &lt;/div&gt;</span></span><br><span class="line"><span class="string">        &lt;/div&gt;</span></span><br><span class="line"><span class="string">      &lt;/div&gt;</span></span><br><span class="line"><span class="string">    &lt;/div&gt;</span></span><br><span class="line"><span class="string">    &quot;&quot;&quot;</span></span><br><span class="line">    components.html(html_data, width=<span class="literal">None</span>, height=<span class="number">300</span>,scrolling=<span class="literal">False</span>)</span><br><span class="line">)</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>呈现 iframe URL用用：<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">streamlit.components.v1.iframe(src, width=<span class="literal">None</span>, height=<span class="literal">None</span>, scrolling=<span class="literal">False</span>)</span><br></pre></td></tr></table></figure>

参数<br>src (str) – 要嵌入的页面的 URL。</li>
</ol>
<p>width (int) – 以 CSS 像素为单位的框架宽度。 默认为报告的默认元素宽度。</p>
<p>height (int) – 以 CSS 像素为单位的框架高度。 默认为 150。</p>
<p>scrolling (bool) – 如果为 True，则在内容大于 iframe 时显示滚动条。 否则，不显示滚动条。 默认为假。<br>例子：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> streamlit <span class="keyword">as</span> st</span><br><span class="line"><span class="keyword">import</span> pandas <span class="keyword">as</span> pd</span><br><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="keyword">import</span> streamlit.components.v1 <span class="keyword">as</span> components</span><br><span class="line"></span><br><span class="line">st.set_page_config( page_title=<span class="string">&quot;Streamlit 练习 &quot;</span>,   layout=<span class="string">&quot;wide&quot;</span> )</span><br><span class="line"></span><br><span class="line">page_html_luckysheet = <span class="string">&quot;&quot;&quot; </span></span><br><span class="line"><span class="string">   &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css&quot; integrity=&quot;sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm&quot; crossorigin=&quot;anonymous&quot;&gt;</span></span><br><span class="line"><span class="string">    &lt;script src=&quot;https://code.jquery.com/jquery-3.2.1.slim.min.js&quot; integrity=&quot;sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;</span></span><br><span class="line"><span class="string">    &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js&quot; integrity=&quot;sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;</span></span><br><span class="line"><span class="string">    &lt;div id=&quot;accordion&quot;&gt;</span></span><br><span class="line"><span class="string">      &lt;div class=&quot;card&quot;&gt;</span></span><br><span class="line"><span class="string">        &lt;div class=&quot;card-header&quot; id=&quot;headingOne&quot;&gt;</span></span><br><span class="line"><span class="string">          &lt;h5 class=&quot;mb-0&quot;&gt;</span></span><br><span class="line"><span class="string">            &lt;button class=&quot;btn btn-link&quot; data-toggle=&quot;collapse&quot; data-target=&quot;#collapseOne&quot; aria-expanded=&quot;true&quot; aria-controls=&quot;collapseOne&quot;&gt;</span></span><br><span class="line"><span class="string">            Collapsible Group Item #1</span></span><br><span class="line"><span class="string">            &lt;/button&gt;</span></span><br><span class="line"><span class="string">          &lt;/h5&gt;</span></span><br><span class="line"><span class="string">        &lt;/div&gt;</span></span><br><span class="line"><span class="string">        &lt;div id=&quot;collapseOne&quot; class=&quot;collapse show&quot; aria-labelledby=&quot;headingOne&quot; data-parent=&quot;#accordion&quot;&gt;</span></span><br><span class="line"><span class="string">          &lt;div class=&quot;card-body&quot;&gt;</span></span><br><span class="line"><span class="string">            Collapsible Group Item #1 content</span></span><br><span class="line"><span class="string">          &lt;/div&gt;</span></span><br><span class="line"><span class="string">        &lt;/div&gt;</span></span><br><span class="line"><span class="string">      &lt;/div&gt;</span></span><br><span class="line"><span class="string">      &lt;div class=&quot;card&quot;&gt;</span></span><br><span class="line"><span class="string">        &lt;div class=&quot;card-header&quot; id=&quot;headingTwo&quot;&gt;</span></span><br><span class="line"><span class="string">          &lt;h5 class=&quot;mb-0&quot;&gt;</span></span><br><span class="line"><span class="string">            &lt;button class=&quot;btn btn-link collapsed&quot; data-toggle=&quot;collapse&quot; data-target=&quot;#collapseTwo&quot; aria-expanded=&quot;false&quot; aria-controls=&quot;collapseTwo&quot;&gt;</span></span><br><span class="line"><span class="string">            Collapsible Group Item #2</span></span><br><span class="line"><span class="string">            &lt;/button&gt;</span></span><br><span class="line"><span class="string">          &lt;/h5&gt;</span></span><br><span class="line"><span class="string">        &lt;/div&gt;</span></span><br><span class="line"><span class="string">        &lt;div id=&quot;collapseTwo&quot; class=&quot;collapse&quot; aria-labelledby=&quot;headingTwo&quot; data-parent=&quot;#accordion&quot;&gt;</span></span><br><span class="line"><span class="string">          &lt;div class=&quot;card-body&quot;&gt;</span></span><br><span class="line"><span class="string">            Collapsible Group Item #2 content</span></span><br><span class="line"><span class="string">          &lt;/div&gt;</span></span><br><span class="line"><span class="string">        &lt;/div&gt;</span></span><br><span class="line"><span class="string">      &lt;/div&gt;</span></span><br><span class="line"><span class="string">    &lt;/div&gt;</span></span><br><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="comment"># st.markdown( page_html_head, unsafe_allow_html=True)</span></span><br><span class="line">container_top = st.container()</span><br><span class="line">container_body = st.container()</span><br><span class="line"></span><br><span class="line"><span class="comment"># Top</span></span><br><span class="line"><span class="keyword">with</span> container_top:</span><br><span class="line">    st.markdown(<span class="string">&quot; [新浪网](https://www.sina.com.cn) /[我的笔记](https://superigbt_superigbt.gitee.io) &quot;</span>)</span><br><span class="line">    st.image(<span class="string">&quot;/home/frankli/temp/建站/banner/mybanner4-1.jpg&quot;</span>,caption=<span class="string">&#x27;my banner&#x27;</span>, use_column_width=<span class="literal">True</span>)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># Body</span></span><br><span class="line"><span class="keyword">with</span> container_body:</span><br><span class="line">    <span class="comment"># components.iframe( &quot;https://superigbt_superigbt.gitee.io/&quot;)</span></span><br><span class="line">    left_side, right_side = st.columns([<span class="number">1</span>,<span class="number">6</span>])</span><br><span class="line">    <span class="comment"># 左边，注意with语句的下一行缩进</span></span><br><span class="line">    <span class="keyword">with</span> left_side: </span><br><span class="line">                    left_side.subheader(<span class="string">&quot; 左边的窄列，预留菜单树 &quot;</span>)</span><br><span class="line">    <span class="comment"># 右边,注意缩进。</span></span><br><span class="line">    <span class="keyword">with</span> right_side: </span><br><span class="line">                    components.html( page_html_luckysheet )</span><br><span class="line">                    components.iframe(<span class="string">&quot;https://superigbt_superigbt.gitee.io&quot;</span>,width=<span class="literal">None</span>, height=<span class="number">600</span>, scrolling=<span class="literal">True</span>)</span><br></pre></td></tr></table></figure>
      
    </div>
    <footer class="article-footer">
      
        <a data-url="https://gitee.com/superigbt_superigbt/superigbt_superigbt/2021/09/10/streamlit-4/" data-id="cl7zulc7p003teiq5h0ob31kj" class="article-share-link" data-share="baidu" data-title="streamlit学习笔记四-----暂称为组件吧">分享到</a>
      

      

      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/streamlit-%E6%A1%86%E6%9E%B6/" rel="tag">streamlit 框架</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/" rel="tag">机器学习</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-pandas_study" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2021/09/02/pandas_study/" class="article-date">
  <time datetime="2021-09-02T09:19:00.000Z" itemprop="datePublished">2021-09-02</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/python%E5%AD%A6%E4%B9%A0/">python学习</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2021/09/02/pandas_study/">panda笔记1</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h5 id="一-Python-将数据框-DataFrame转为html表格-DataFrame-to-html-详解"><a href="#一-Python-将数据框-DataFrame转为html表格-DataFrame-to-html-详解" class="headerlink" title="一. Python 将数据框 DataFrame转为html表格,DataFrame.to_html()详解"></a>一. Python 将数据框 DataFrame转为html表格,DataFrame.to_html()详解</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">DataFrame.to_html(buf=<span class="literal">None</span>, columns=<span class="literal">None</span>, col_space=<span class="literal">None</span>, header=<span class="literal">True</span>, index=<span class="literal">True</span>,na_rep=<span class="string">&#x27;NaN&#x27;</span>, formatters=<span class="literal">None</span>,</span><br><span class="line">				  float_format=<span class="literal">None</span>, sparsify=<span class="literal">None</span>, index_names=<span class="literal">True</span>,justify=<span class="literal">None</span>, bold_rows=<span class="literal">True</span>,classes=<span class="literal">None</span>,</span><br><span class="line">				  escape=<span class="literal">True</span>, max_rows=<span class="literal">None</span>, max_cols=<span class="literal">None</span>,show_dimensions=<span class="literal">False</span>, notebook=<span class="literal">False</span>, decimal=<span class="string">&#x27;.&#x27;</span>,</span><br><span class="line">				  border=<span class="literal">None</span>)</span><br></pre></td></tr></table></figure>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">buf : StringIO-like, 可选</span><br><span class="line">    写入缓冲区。</span><br><span class="line">columns : sequence，可选</span><br><span class="line">    要转化的列的列名；默认值 None 为所有列转化。</span><br><span class="line">col_space : int，可选</span><br><span class="line">    每列的最小宽度。</span><br><span class="line">header : bool，可选</span><br><span class="line">    是否打印列标签，默认为 True。</span><br><span class="line">index : 布尔值，可选</span><br><span class="line">    是否打印索引（行）标签，默认为 True。</span><br><span class="line">na_rep : 字符串，可选</span><br><span class="line">    指定 NAN 的字符串表示形式，默认为 &#x27;NaN&#x27;。</span><br><span class="line">formatters : 多个单参数函数组成的列表或字典，可选</span><br><span class="line">    格式化程序可按列表的所索引或字典的键名称应用于列元素，默认为 None。</span><br><span class="line">    每个单参数函数的结果必须是一个 unicode 字符串。列表的长度必须等于列数。</span><br><span class="line">float_format: 单参数函数，可选</span><br><span class="line">    用于将列元素设置为浮点数的格式化程序功能，默认为无。</span><br><span class="line">    此单参数函数的结果必须是 unicode 字符串。</span><br><span class="line">sparsify : bool，可选</span><br><span class="line">    默认为 True。输入 False 时，对于具有层次结构索引的 DataFrame，会在每一行打印多重索引。</span><br><span class="line">index_names : bool，可选</span><br><span class="line">    打印索引名称，默认为 True。</span><br><span class="line">line_width : int，可选</span><br><span class="line">    换行符的宽度，默认为不换行。</span><br><span class="line">justify : 列标签对齐方式, 可选</span><br><span class="line">    左右对齐列标签。默认为 None时，使用打印配置中的选项（由 set_option 控制），则右对齐。</span><br><span class="line">bold_rows : bool, 可选</span><br><span class="line">    对横向表格线进行加粗。</span><br><span class="line">classes : CSS类(es)适用于生成的html表, 可选</span><br><span class="line">    默认 None</span><br><span class="line">escape : bool, 可选</span><br><span class="line">    将 &quot;&lt;&quot;, &quot;&gt;&quot;, &quot;&amp;&quot; 转化成 html 安全序列（？？），默认 True。</span><br><span class="line">max_rows : int, 可选</span><br><span class="line">    显示最大行数。</span><br><span class="line">max_cols : int, 可选</span><br><span class="line">    显示最大列数。</span><br><span class="line">decimal : str, 可选</span><br><span class="line">    小数分隔符, 默认为 &#x27;.&#x27;。</span><br><span class="line">border : int， 可选</span><br><span class="line">    表格外边框宽度，默认为 1，参数为 0 时表格无边框。数值越大外边框越宽。</span><br></pre></td></tr></table></figure>
<h5 id="二-pd-read-excel方法说明"><a href="#二-pd-read-excel方法说明" class="headerlink" title="二. pd.read_excel方法说明"></a>二. pd.read_excel方法说明</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">pd.read_excel(io, sheet_name=<span class="number">0</span>, header=<span class="number">0</span>, names=<span class="literal">None</span>,      index_col=<span class="literal">None</span>, </span><br><span class="line">       usecols=<span class="literal">None</span>, squeeze=<span class="literal">False</span>,dtype=<span class="literal">None</span>, engine=<span class="literal">None</span>, </span><br><span class="line">       converters=<span class="literal">None</span>, true_values=<span class="literal">None</span>, false_values=<span class="literal">None</span>, </span><br><span class="line">       skiprows=<span class="literal">None</span>, nrows=<span class="literal">None</span>, na_values=<span class="literal">None</span>, parse_dates=<span class="literal">False</span>, </span><br><span class="line">       date_parser=<span class="literal">None</span>, thousands=<span class="literal">None</span>, comment=<span class="literal">None</span>, skipfooter=<span class="number">0</span>, </span><br><span class="line">       convert_float=<span class="literal">True</span>, **kwds)</span><br></pre></td></tr></table></figure>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">io：excel文件</span><br><span class="line">sheet_name：返回指定sheet，默认索引0返回第一个，也可用名称，如果返回多个则可用列表，为None则返回全表</span><br><span class="line">header：指定表头，也可用列表指定多行</span><br><span class="line">names：自定义列名，长度和Excel列长度必须一致</span><br><span class="line">index_col：用作索引的列</span><br><span class="line">usecols：读取指定的列，参数为列表，如[0,1]表示第1和第2列</span><br></pre></td></tr></table></figure>
<h5 id="三-使用to-excel-函数将DataFrame导出到excel文件"><a href="#三-使用to-excel-函数将DataFrame导出到excel文件" class="headerlink" title="三. 使用to_excel()函数将DataFrame导出到excel文件"></a>三. 使用to_excel()函数将DataFrame导出到excel文件</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">DataFrame.to_excel(excel_writer, sheet_name=<span class="string">&#x27;Sheet1&#x27;</span>, na_rep=<span class="string">&#x27;&#x27;</span>, float_format=<span class="literal">None</span>, columns=<span class="literal">None</span>,</span><br><span class="line">        header=<span class="literal">True</span>, index=<span class="literal">True</span>, index_label=<span class="literal">None</span>, startrow=<span class="number">0</span>, startcol=<span class="number">0</span>, engine=<span class="literal">None</span>, merge_cells=<span class="literal">True</span>,</span><br><span class="line">        encoding=<span class="literal">None</span>, inf_rep=<span class="string">&#x27;inf&#x27;</span>, verbose=<span class="literal">True</span>, freeze_panes=<span class="literal">None</span>)</span><br></pre></td></tr></table></figure>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">excel_writer：文件路径或现有的ExcelWriter。</span><br><span class="line">sheet_name：它是指包含DataFrame的工作表的名称。</span><br><span class="line">na_rep：指定要写入的表如果有空值（NAN）,则需要填入的字符串。</span><br><span class="line">float_format：这是一个可选参数, 用于格式化浮点数字符串。</span><br><span class="line">columns：指定哪些列要写入新表。</span><br><span class="line">header：是否把列名也写入excel表，默认为True，即写入</span><br><span class="line">index：是否把索引也写入excel表，默认为True，即写入。</span><br><span class="line">index_label：引用索引列的列标签。如果未指定, 并且标头和索引为True, 则使用索引名称。如果DataFrame使用MultiIndex, 则应给出一个序列。</span><br><span class="line">startrow：默认值0。它指向转储DataFrame的左上单元格行。</span><br><span class="line">startcol：默认值0。它指向转储DataFrame的左上方单元格列。</span><br><span class="line">engine：这是一个可选参数, 用于写入要使用的引擎, openpyxl或xlsxwriter。</span><br><span class="line">merge_cells：返回布尔值, 其默认值为True。它将MultiIndex和Hierarchical行写为合并的单元格。</span><br><span class="line">encoding：这是一个可选参数, 可对生成的excel文件进​​行编码。仅对于xlwt是必需的。</span><br><span class="line">inf_rep：它也是一个可选参数, 默认值为inf。它通常表示无穷大。</span><br><span class="line">verbose：返回一个布尔值。它的默认值为True。</span><br><span class="line">它用于在错误日志中显示更多信息。</span><br><span class="line">Frozen_panes：它也是一个可选参数, 用于指定要冻结的最底部一行和最右边一列。</span><br><span class="line"></span><br></pre></td></tr></table></figure>
      
    </div>
    <footer class="article-footer">
      
        <a data-url="https://gitee.com/superigbt_superigbt/superigbt_superigbt/2021/09/02/pandas_study/" data-id="cl7zulc780036eiq5b6mi18hb" class="article-share-link" data-share="baidu" data-title="panda笔记1">分享到</a>
      

      

      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/pandas%E5%AD%A6%E4%B9%A0/" rel="tag">pandas学习</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%BB%BA%E7%AB%99/" rel="tag">建站</a></li></ul>

    </footer>
  </div>
  
</article>


  


  <nav id="page-nav">
    <a class="extend prev" rel="prev" href="/page/2/">&amp;laquo; 上一页</a><a class="page-number" href="/">1</a><a class="page-number" href="/page/2/">2</a><span class="page-number current">3</span><a class="page-number" href="/page/4/">4</a><a class="page-number" href="/page/5/">5</a><span class="space">&hellip;</span><a class="page-number" href="/page/10/">10</a><a class="extend next" rel="next" href="/page/4/">下一页 &amp;raquo;</a>
  </nav>
</section>
      
      <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">分类</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/Linux/">Linux</a><span class="category-list-count">5</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/VirtualBox/">VirtualBox</a><span class="category-list-count">5</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/caddy/">caddy</a><span class="category-list-count">4</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/cygwin/">cygwin</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/hexo/">hexo</a><span class="category-list-count">5</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/linux%E6%A1%8C%E9%9D%A2/">linux桌面</a><span class="category-list-count">4</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/mysql/">mysql</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/python%E5%AD%A6%E4%B9%A0/">python学习</a><span class="category-list-count">19</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/termux/">termux</a><span class="category-list-count">20</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/termux/caddy/">caddy</a><span class="category-list-count">1</span></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/ubuntu%E7%BB%8F%E9%AA%8C/">ubuntu经验</a><span class="category-list-count">12</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/win10/">win10</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E5%BB%BA%E7%AB%99/">建站</a><span class="category-list-count">3</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E5%BC%80%E5%85%B3%E7%94%B5%E6%BA%90/">开关电源</a><span class="category-list-count">3</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E5%BF%AB%E6%8D%B7%E9%94%AE/">快捷键</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E6%89%8B%E6%9C%BA%E7%94%B5%E8%84%91%E4%BA%92%E8%81%94/">手机电脑互联</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E6%91%98%E6%8A%84%E4%B8%8E%E9%9A%8F%E7%AC%94/">摘抄与随笔</a><span class="category-list-count">10</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">标签</h3>
    <div class="widget">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/Anlinux/" rel="tag">Anlinux</a><span class="tag-list-count">10</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/LAMP/" rel="tag">LAMP</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Linux/" rel="tag">Linux</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Linux%E8%AE%BE%E7%BD%AE/" rel="tag">Linux设置</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/caddy/" rel="tag">caddy</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/caddy-PHP/" rel="tag">caddy+PHP</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/caddy-Vtiger/" rel="tag">caddy+Vtiger</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/caddyV2/" rel="tag">caddyV2</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/code-server/" rel="tag">code-server</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/cygwin/" rel="tag">cygwin</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/flask%E6%A1%86%E6%9E%B6/" rel="tag">flask框架</a><span class="tag-list-count">10</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/fluxbox/" rel="tag">fluxbox</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hexo/" rel="tag">hexo</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hexo%E4%B8%BB%E9%A2%98/" rel="tag">hexo主题</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hexo%E5%AE%89%E8%A3%85/" rel="tag">hexo安装</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hexo%E9%83%A8%E7%BD%B2/" rel="tag">hexo部署</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/icewm/" rel="tag">icewm</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/lamp-phpmyadmin/" rel="tag">lamp+phpmyadmin</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/linux/" rel="tag">linux</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/lumina%E6%A1%8C%E9%9D%A2/" rel="tag">lumina桌面</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/markdown%E8%A1%A8%E6%A0%BC/" rel="tag">markdown表格</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mysql/" rel="tag">mysql</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nodejs/" rel="tag">nodejs</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/openbox/" rel="tag">openbox</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/pandas%E5%AD%A6%E4%B9%A0/" rel="tag">pandas学习</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/qemu/" rel="tag">qemu</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sftp/" rel="tag">sftp</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ssh/" rel="tag">ssh</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/streamlit-%E6%A1%86%E6%9E%B6/" rel="tag">streamlit 框架</a><span class="tag-list-count">8</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/termux/" rel="tag">termux</a><span class="tag-list-count">12</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/termux-proot-distro/" rel="tag">termux-proot-distro</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/termux%E6%A1%8C%E9%9D%A2/" rel="tag">termux桌面</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ternux/" rel="tag">ternux</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/tmux/" rel="tag">tmux</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ubtunu%E7%89%88%E6%9C%AC/" rel="tag">ubtunu版本</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ubuntu-reWifi/" rel="tag">ubuntu-reWifi</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ubuntu%E4%BF%AE%E6%94%B9DNS/" rel="tag">ubuntu修改DNS</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ubuntu%E7%BB%8F%E9%AA%8C/" rel="tag">ubuntu经验</a><span class="tag-list-count">7</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vim/" rel="tag">vim</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vscode/" rel="tag">vscode</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wcode/" rel="tag">wcode</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/webbrowser-termux/" rel="tag">webbrowser termux</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%8D%9A%E5%AE%A2/" rel="tag">博客</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%BB%BA%E7%AB%99/" rel="tag">建站</a><span class="tag-list-count">18</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%BC%80%E5%85%B3%E7%94%B5%E6%BA%90%E5%9F%BA%E7%A1%80/" rel="tag">开关电源基础</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%89%8B%E6%9C%BA%E6%8A%95%E5%B1%8F%E8%BD%AF%E4%BB%B6scrcpy/" rel="tag">手机投屏软件scrcpy</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%8D%A2%E6%BA%90/" rel="tag">换源</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%8E%A7%E5%88%B6%E5%8F%B0/" rel="tag">控制台</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%97%85%E6%B8%B8%E6%94%BB%E7%95%A5/" rel="tag">旅游攻略</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/" rel="tag">机器学习</a><span class="tag-list-count">8</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%9E%81%E7%AE%80%E6%A1%8C%E9%9D%A2/" rel="tag">极简桌面</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%A8%A1%E6%8B%9F%E5%99%A8-%E8%99%9A%E6%8B%9F%E6%9C%BA/" rel="tag">模拟器&#x2F;虚拟机</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E7%B3%BB%E7%BB%9F%E5%AE%89%E8%A3%85/" rel="tag">系统安装</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E7%BC%96%E8%BE%91%E5%99%A8/" rel="tag">编辑器</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%99%9A%E6%8B%9F%E6%9C%BA/" rel="tag">虚拟机</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%B6%A3%E8%A8%80/" rel="tag">趣言</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%BF%9C%E7%A8%8B%E6%A1%8C%E9%9D%A2/" rel="tag">远程桌面</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E9%9A%8F%E7%AC%94/" rel="tag">随笔</a><span class="tag-list-count">4</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">标签云</h3>
    <div class="widget tagcloud">
      <a href="/tags/Anlinux/" style="font-size: 18px;">Anlinux</a> <a href="/tags/LAMP/" style="font-size: 10px;">LAMP</a> <a href="/tags/Linux/" style="font-size: 13px;">Linux</a> <a href="/tags/Linux%E8%AE%BE%E7%BD%AE/" style="font-size: 10px;">Linux设置</a> <a href="/tags/caddy/" style="font-size: 11px;">caddy</a> <a href="/tags/caddy-PHP/" style="font-size: 10px;">caddy+PHP</a> <a href="/tags/caddy-Vtiger/" style="font-size: 10px;">caddy+Vtiger</a> <a href="/tags/caddyV2/" style="font-size: 10px;">caddyV2</a> <a href="/tags/code-server/" style="font-size: 10px;">code-server</a> <a href="/tags/cygwin/" style="font-size: 11px;">cygwin</a> <a href="/tags/flask%E6%A1%86%E6%9E%B6/" style="font-size: 18px;">flask框架</a> <a href="/tags/fluxbox/" style="font-size: 10px;">fluxbox</a> <a href="/tags/hexo/" style="font-size: 10px;">hexo</a> <a href="/tags/hexo%E4%B8%BB%E9%A2%98/" style="font-size: 10px;">hexo主题</a> <a href="/tags/hexo%E5%AE%89%E8%A3%85/" style="font-size: 10px;">hexo安装</a> <a href="/tags/hexo%E9%83%A8%E7%BD%B2/" style="font-size: 11px;">hexo部署</a> <a href="/tags/icewm/" style="font-size: 10px;">icewm</a> <a href="/tags/lamp-phpmyadmin/" style="font-size: 11px;">lamp+phpmyadmin</a> <a href="/tags/linux/" style="font-size: 14px;">linux</a> <a href="/tags/lumina%E6%A1%8C%E9%9D%A2/" style="font-size: 10px;">lumina桌面</a> <a href="/tags/markdown%E8%A1%A8%E6%A0%BC/" style="font-size: 10px;">markdown表格</a> <a href="/tags/mysql/" style="font-size: 11px;">mysql</a> <a href="/tags/nodejs/" style="font-size: 10px;">nodejs</a> <a href="/tags/openbox/" style="font-size: 10px;">openbox</a> <a href="/tags/pandas%E5%AD%A6%E4%B9%A0/" style="font-size: 10px;">pandas学习</a> <a href="/tags/qemu/" style="font-size: 10px;">qemu</a> <a href="/tags/sftp/" style="font-size: 10px;">sftp</a> <a href="/tags/ssh/" style="font-size: 11px;">ssh</a> <a href="/tags/streamlit-%E6%A1%86%E6%9E%B6/" style="font-size: 17px;">streamlit 框架</a> <a href="/tags/termux/" style="font-size: 19px;">termux</a> <a href="/tags/termux-proot-distro/" style="font-size: 10px;">termux-proot-distro</a> <a href="/tags/termux%E6%A1%8C%E9%9D%A2/" style="font-size: 12px;">termux桌面</a> <a href="/tags/ternux/" style="font-size: 10px;">ternux</a> <a href="/tags/tmux/" style="font-size: 10px;">tmux</a> <a href="/tags/ubtunu%E7%89%88%E6%9C%AC/" style="font-size: 10px;">ubtunu版本</a> <a href="/tags/ubuntu-reWifi/" style="font-size: 10px;">ubuntu-reWifi</a> <a href="/tags/ubuntu%E4%BF%AE%E6%94%B9DNS/" style="font-size: 10px;">ubuntu修改DNS</a> <a href="/tags/ubuntu%E7%BB%8F%E9%AA%8C/" style="font-size: 16px;">ubuntu经验</a> <a href="/tags/vim/" style="font-size: 10px;">vim</a> <a href="/tags/vscode/" style="font-size: 11px;">vscode</a> <a href="/tags/wcode/" style="font-size: 10px;">wcode</a> <a href="/tags/webbrowser-termux/" style="font-size: 10px;">webbrowser termux</a> <a href="/tags/%E5%8D%9A%E5%AE%A2/" style="font-size: 13px;">博客</a> <a href="/tags/%E5%BB%BA%E7%AB%99/" style="font-size: 20px;">建站</a> <a href="/tags/%E5%BC%80%E5%85%B3%E7%94%B5%E6%BA%90%E5%9F%BA%E7%A1%80/" style="font-size: 12px;">开关电源基础</a> <a href="/tags/%E6%89%8B%E6%9C%BA%E6%8A%95%E5%B1%8F%E8%BD%AF%E4%BB%B6scrcpy/" style="font-size: 10px;">手机投屏软件scrcpy</a> <a href="/tags/%E6%8D%A2%E6%BA%90/" style="font-size: 11px;">换源</a> <a href="/tags/%E6%8E%A7%E5%88%B6%E5%8F%B0/" style="font-size: 10px;">控制台</a> <a href="/tags/%E6%97%85%E6%B8%B8%E6%94%BB%E7%95%A5/" style="font-size: 11px;">旅游攻略</a> <a href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/" style="font-size: 17px;">机器学习</a> <a href="/tags/%E6%9E%81%E7%AE%80%E6%A1%8C%E9%9D%A2/" style="font-size: 10px;">极简桌面</a> <a href="/tags/%E6%A8%A1%E6%8B%9F%E5%99%A8-%E8%99%9A%E6%8B%9F%E6%9C%BA/" style="font-size: 15px;">模拟器/虚拟机</a> <a href="/tags/%E7%B3%BB%E7%BB%9F%E5%AE%89%E8%A3%85/" style="font-size: 14px;">系统安装</a> <a href="/tags/%E7%BC%96%E8%BE%91%E5%99%A8/" style="font-size: 14px;">编辑器</a> <a href="/tags/%E8%99%9A%E6%8B%9F%E6%9C%BA/" style="font-size: 11px;">虚拟机</a> <a href="/tags/%E8%B6%A3%E8%A8%80/" style="font-size: 13px;">趣言</a> <a href="/tags/%E8%BF%9C%E7%A8%8B%E6%A1%8C%E9%9D%A2/" style="font-size: 11px;">远程桌面</a> <a href="/tags/%E9%9A%8F%E7%AC%94/" style="font-size: 13px;">随笔</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">归档</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2022/10/">十月 2022</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2022/09/">九月 2022</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2022/06/">六月 2022</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2022/05/">五月 2022</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2022/03/">三月 2022</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2022/02/">二月 2022</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2022/01/">一月 2022</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/12/">十二月 2021</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/11/">十一月 2021</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/10/">十月 2021</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/09/">九月 2021</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/08/">八月 2021</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/07/">七月 2021</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/06/">六月 2021</a><span class="archive-list-count">10</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/03/">三月 2021</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/02/">二月 2021</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/01/">一月 2021</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/11/">十一月 2020</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/10/">十月 2020</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/09/">九月 2020</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/08/">八月 2020</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/07/">七月 2020</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/06/">六月 2020</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/05/">五月 2020</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/04/">四月 2020</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/03/">三月 2020</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/02/">二月 2020</a><span class="archive-list-count">7</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">近期文章</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2022/10/08/linux-calibrate-screen-colors/">Ubuntu 屏幕颜色校准</a>
          </li>
        
          <li>
            <a href="/2022/10/07/debootstrap2/">debootstrap学习笔记2</a>
          </li>
        
          <li>
            <a href="/2022/10/06/debootstrap1/">debootstrap学习笔记1</a>
          </li>
        
          <li>
            <a href="/2022/10/06/ubuntu-install-wine/">ubuntu安装Wine</a>
          </li>
        
          <li>
            <a href="/2022/09/13/excerpt6/">摘抄2---中国真心不容易</a>
          </li>
        
      </ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">友情链接</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="https://superigbt_superigbt.gitee.io/" target="_blank">My-gitee</a>
          </li>
        
          <li>
            <a href="https://superigbt.github.io/" target="_blank">My-github</a>
          </li>
        
          <li>
            <a href="https://hexo.io/themes/" target="_blank">Hexo主题</a>
          </li>
        
          <li>
            <a href="https://github.com/termux/termux-app/releases" target="_blank">Texmux神器</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
      
    </div>
    <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2022 Frank.Li<br>
      Powered by <a href="//hexo.io/" target="_blank">Hexo</a>
      .
      Theme by <a href="https://github.com/xiangming/landscape-plus" target="_blank">Landscape-plus</a>
    </div>
  </div>
</footer>
  </div>
  <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">首页</a>
  
    <a href="/archives" class="mobile-nav-link">按时间</a>
  
    <a href="/about" class="mobile-nav-link">关于我</a>
  
    <a href="/categories/%E6%91%98%E6%8A%84%E4%B8%8E%E9%9A%8F%E7%AC%94" class="mobile-nav-link">摘抄，随笔</a>
  
    <a href="/categories/%E5%BC%80%E5%85%B3%E7%94%B5%E6%BA%90" class="mobile-nav-link">开关电源</a>
  
</nav>
  <!-- totop start -->
<div id="totop">
<a title="返回顶部"><img src="/img/scrollup.png"/></a>
</div>

<!-- totop end -->


<!-- 百度分享 start -->

<div id="article-share-box" class="article-share-box">
  <div id="bdshare" class="bdsharebuttonbox article-share-links">
    <a class="article-share-weibo" data-cmd="tsina" title="分享到新浪微博"></a>
    <a class="article-share-weixin" data-cmd="weixin" title="分享到微信"></a>
    <a class="article-share-qq" data-cmd="sqq" title="分享到QQ"></a>
    <a class="article-share-renren" data-cmd="renren" title="分享到人人网"></a>
    <a class="article-share-more" data-cmd="more" title="更多"></a>
  </div>
</div>
<script>
  function SetShareData(cmd, config) {
    if (shareDataTitle && shareDataUrl) {
      config.bdText = shareDataTitle;
      config.bdUrl = shareDataUrl;
    }
    return config;
  }
  window._bd_share_config={
    "common":{onBeforeClick: SetShareData},
    "share":{"bdCustomStyle":"/css/bdshare.css"}
  };
  with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='//bdimg.share.baidu.com/static/api/js/share.js?cdnversion='+~(-new Date()/36e5)];
</script>

<!-- 百度分享 end -->

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>





<script src="/js/script.js"></script>


</div>
</body>
</html>
